package com.rongxun.widget;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.rongxun.hbwallet.R;


/**
 * 创建者     庄丰泽
 * 创建时间   2018/6/26 18:45
 * 描述
 */
public class CustomWaitDialog extends Dialog {
    private Context context;
    private String  msg=""; //跟随Dialog 一起显示的message 信息！
    private boolean cancelable;
    public CustomWaitDialog(Context context, int theme, String msg,boolean cancelable) {
        super(context, theme);
        this.context = context;
        this.msg = msg;
        this.cancelable=cancelable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = View.inflate(context, R.layout.dialog_loading,null);
        ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressbar);
        progressBar.getIndeterminateDrawable()
                .setColorFilter(Color.parseColor("#01AA80"), PorterDuff.Mode.SRC_IN);
        TextView text=(TextView)view.findViewById(R.id.tv_loading_msg);
        text.setText(msg);
        this.setCanceledOnTouchOutside(false);
        this.setCancelable(cancelable);// 不可以用“返回键”取消
        this.setContentView(view, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT));// 设置布局

    }
}
